using System.Collections.Generic;

namespace sql_train
{
    public class Utils
    {
        public static bool CollectionsEqual<T>(IList<T> one, IList<T> two)
        {
            if (ReferenceEquals(one, two)) return true;

            if (one.Count != two.Count) return false;

            for (int i = 0; i < one.Count; i++)
            {
                if (!Equals(one[i], two[i])) return false;
            }

            return true;
        }

        public static int GetCollectionHashCode<T>(IList<T> collection)
        {
            if (collection == null) return 0;

            int hashcode = collection.Count.GetHashCode();
            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i] != null) hashcode ^= collection[i].GetHashCode()*397;
            }
            return hashcode;
        }
    }
}